package cn.edu.xmist.thread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zhongjinbin (jinbin.zhong@nascent.cn)
 * @version 1.0.0
 * @date 2020/11/27 11:56
 * @description 测试线程销毁之前的额外处理事件（JVM）
 */
public class ThreadPoolTest {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService pool = Executors.newFixedThreadPool(10);

        // 为线程池的线程分配任务
        ThreadShutdownHook threadPoolDemo = new ThreadShutdownHook();
        pool.submit(threadPoolDemo);

        // 关闭线程池,调用线程的JVM销毁之前的钩子
        pool.shutdownNow(); // 平滑的关闭，等待现有任务执行完毕。shutdownNow()直接关闭。*/
    }
}
